CC_HOME = d:/mingw
BIN = bin/
PROGRAM = $(BIN)json-rpc.exe 
SRCDIRS = $(shell find ./src -maxdepth 1 -type d)
SRCEXTS = .c
INCLUDES = -I${CC_HOME}/include -I./src -I./src/json -I./src/libsoup/include/libsoup-2.4 -I./src/glib/include/glib-2.0 -I./src/glib/include/glib-2.0/glib -I./src/glib/lib/glib-2.0/include
LIBS = -L${CC_HOME}/lib -L./src/glib/lib -L./src/libsoup/lib
CFLAGS = -std=c99 -g3 -Wall -O2 -finput-charset=UTF-8 -fexec-charset=UTF-8 -DNDEBUG=1 -DGLIB_DEPRECATED -DTHREADSAFE=1 -DHAVE_CONFIG_H -U__STRICT_ANSI__
LDFLAGS = -lglib-2.0.dll -lgio-2.0.dll -lgobject-2.0.dll -lgthread-2.0.dll -lsoup-2.4.dll -lgdiplus -lole32 -loleaut32 -luuid
CC = gcc
SRCS = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(SRCEXTS))))
OBJS = $(foreach x,$(SRCEXTS),$(patsubst %$(x),%.o,$(filter %$(x),$(SRCS))))
.PHONY : cleanall
all : $(PROGRAM)
objs : $(OBJS)
%.o : %.c
	$(CC) $(CFLAGS) -c $(@D)/$(<F) -o $(@D)/$(@F) ${INCLUDES}
$(PROGRAM) : $(OBJS)
	$(CC) -o $(PROGRAM) $(OBJS) ${LIBS} $(LDFLAGS)
rebuild: clean all
clean : 
	rm -f *.o
cleanall: clean
	rm -f *.o
